package com.example.service;

import com.example.entity.MapOptions;
import com.example.mapper.MapOptionsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
问题选项业务处理
 */
@Service
public class MapOptionsService {

    @Resource
    private MapOptionsMapper mapoptionsMapper;

    public void add(MapOptions mapoptions) {
        mapoptionsMapper.insert(mapoptions);
    }

    public void deleteById(Integer id) {
        mapoptionsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(MapOptions mapoptions) {
        mapoptionsMapper.updateById(mapoptions);
    }

    public MapOptions selectById(Integer id) {
        return mapoptionsMapper.selectById(id);
    }

    public List<MapOptions> selectAll(MapOptions mapoptions) {
        return mapoptionsMapper.selectAll(mapoptions);
    }

    public PageInfo<MapOptions> selectPage(MapOptions mapoptions, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MapOptions> optionsList = mapoptionsMapper.selectAll(mapoptions);
        return PageInfo.of(optionsList);
    }
}
